//
//  XLPlayer.h
//  FFMpegKitDemo
//
//  Created by ilongge on 2023/8/2.
//

#import <UIKit/UIKit.h>

@class XLPlayerItem;
@class XLPlayerConfig;

typedef NS_ENUM(NSInteger, XLPlayerStatus) {
    XLPlayerStatusNone,
    XLPlayerStatusOpening,
    XLPlayerStatusOpened,
    XLPlayerStatusPlaying,
    XLPlayerStatusBuffering,
    XLPlayerStatusPaused,
    XLPlayerStatusEOF,
    XLPlayerStatusClosing,
    XLPlayerStatusClosed,
};

@interface XLPlayer : UIView
/**
 * 类方法
 * Class Method
 * 初始化播放器，若初始化失败，可读取error字段值。
 * Initialize the player. If initialization failed, read error.
 * @param  URL 资源链接 / Resource URL
 * @param  config 播放器配置 / Player Configuration
 * @param  error 错误 / Error
 * @return 播放器实例 / XLPlayer Instance
 */
+ (instancetype)playerWithURL:(NSURL *)URL config:(XLPlayerConfig *)config error:(NSError **)error;
/**
 * 类方法
 * Class Method
 * 初始化播放器，若初始化失败，可读取error值。
 * Initialize the player. If initialization failed, read error.
 * @param  item 资源对象 / Resource Item
 * @param  config 播放器配置 / Player Configuration
 * @param  error 错误 / Error
 * @return 播放器实例 / XLPlayer Instance
 */
+ (instancetype)playerWithPlayerItem:(XLPlayerItem *)item config:(XLPlayerConfig *)config error:(NSError **)error;
/**
 * 实例方法
 * Instance Method
 * 初始化播放器，若初始化失败，可读取error值。
 * Initialize the player. If initialization failed, read error.
 * @param  URL 资源链接 / Resource URL
 * @param  config 播放器配置 / Player Configuration
 * @param  error 错误 / Error
 * @return 播放器实例 / XLPlayer Instance
 */
- (instancetype)initWithURL:(NSURL *)URL config:(XLPlayerConfig *)config error:(NSError **)error;
/**
 * 实例方法
 * Instance Method
 * 初始化播放器，若初始化失败，可读取error值。
 * Initialize the player. If initialization failed, read error.
 * @param  item 资源对象 / Resource Item
 * @param  config 播放器配置 / Player Configuration
 * @param  error 错误 / Error
 * @return 播放器实例 / XLPlayer Instance
 */
- (instancetype)initWithPlayerItem:(XLPlayerItem *)item config:(XLPlayerConfig *)config error:(NSError **)error;
/**
 * 播放器当前的配置
 * Current configuration of the player
 */
@property (readonly, strong, nonatomic) XLPlayerConfig *config;
/**
 * 播放器当前的资源地址
 * Current resource URL of the player
 */
@property (readonly, strong, nonatomic) NSURL *url;
/**
 * 播放器当前的资源item
 * Current resource item of the player
 */
@property (readonly, strong, nonatomic) XLPlayerItem *item;
/**
 * 播放器状态
 * Current status of the player
 */
@property (readonly, assign, nonatomic) XLPlayerStatus status;
/**
 * 获取当前视频帧的截图
 * A screenshot of the current video frame
 */
- (UIImage *)screenshot:(CGSize)imageSize;
/**
 * 准备播放
 * Prepare To Play
 */
- (BOOL)prepareToPlayError:(NSError * *)error;
/**
 * 播放
 * Play
 */
- (void)play;
/**
 * 暂停
 * Pause
 */
- (void)pause;
/**
 * 关闭播放器
 * Close Player
 */
- (void)close;
@end


